qafeer_game_devfandomcom-20200214-history
Publishing natively with PhoneGap
Once you're done making a game, you may want to package your app and sell it natively on an appstore. PhoneGap is a great tool that can help you do just that. AppGyver is another good alternative. PhoneGap lets you compile and build native apps by giving you a wrapper for your HTML5 apps. You can either install the native SDK of each platform, in which case you'll have full control of everything, but it comes at the cost of having to set up the development environment. Or you can just upload your HTML files and the cloud will build it into a native app for you automatically. The drawback to this is approach is that it only gives you the first app for free (but you can have unlimited apps if they're open source) but we'll be using this cloud approach for simplicity. Prerequisites Before we get started, make sure you have all of the following ready: # An Adobe account. Make sure you can sign in here https://build.phonegap.com # Install Node.js https://nodejs.org/ # Install Phonegap http://phonegap.com/install/ Getting started with a sample app Once you have everything installed correctly, creating and compiling a sample app is very easy. # Create an app. You can do this by running " phonegap create SampleApp " # The www folder is where the app itself is. Take a look at index.html and make any modifications you like. # Create a zip file of everything inside the www folder (such that index.html is in the root of this archive). # Go to https://build.phonegap.com/apps and upload your app zip file # Sit back, watch the cloud build service compile your app, and download the native file and run it on your phone! If everything went right, you should have native Android and Windows phone downloads. (For iOS you need to enter a developer certificate key if you have one). Your app is now ready for deployment! Integrating it with Phaser Now that's just the default PhoneGap app, what if we wanted to put a project made with Phaser in? It's no different from making any web app. The important thing is to keep the head tag, and replace the body tag with your own code, but make sure to keep these lines: You can see an example Phaser app in the Github repository provided with this course. Extending with native code and plugins At this point, you might be happy with being able to compile native applications. However, during release you might need to connect to various native API's, such as ads, or micro-transactions, or Camera/File API's of the phone. This is beyond the scope of this course, but PhoneGap does provide a robust system to allow you to do all this with plugins. Be sure to check out the documentation and community for resources and guidance: http://docs.build.phonegap.com/en_US/#googtrans(en) Challenges * Can you port one of our examples to run on your phone? (The example app provided is a port of the falling physics boxes example, modified to use touch events instead of mouse)